/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package org.topcased.SimplePDL.impl;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

import org.topcased.SimplePDL.Guidance;
import org.topcased.SimplePDL.ProcessElement;
import org.topcased.SimplePDL.Resource;
import org.topcased.SimplePDL.ResourceType;
import org.topcased.SimplePDL.SimplePDLPackage;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Process</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link org.topcased.SimplePDL.impl.ProcessImpl#getName <em>Name</em>}</li>
 *   <li>{@link org.topcased.SimplePDL.impl.ProcessImpl#getProcessElements <em>Process Elements</em>}</li>
 *   <li>{@link org.topcased.SimplePDL.impl.ProcessImpl#getMinTime <em>Min Time</em>}</li>
 *   <li>{@link org.topcased.SimplePDL.impl.ProcessImpl#getMaxTime <em>Max Time</em>}</li>
 *   <li>{@link org.topcased.SimplePDL.impl.ProcessImpl#getResources <em>Resources</em>}</li>
 *   <li>{@link org.topcased.SimplePDL.impl.ProcessImpl#getGuidanceGFX <em>Guidance GFX</em>}</li>
 *   <li>{@link org.topcased.SimplePDL.impl.ProcessImpl#getResourcesGFX <em>Resources GFX</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class ProcessImpl extends EObjectImpl implements org.topcased.SimplePDL.Process {
	/**
	 * The default value of the '{@link #getName() <em>Name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getName()
	 * @generated
	 * @ordered
	 */
	protected static final String NAME_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getName() <em>Name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getName()
	 * @generated
	 * @ordered
	 */
	protected String name = NAME_EDEFAULT;

	/**
	 * The cached value of the '{@link #getProcessElements() <em>Process Elements</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getProcessElements()
	 * @generated
	 * @ordered
	 */
	protected EList<ProcessElement> processElements;

	/**
	 * The default value of the '{@link #getMinTime() <em>Min Time</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getMinTime()
	 * @generated
	 * @ordered
	 */
	protected static final int MIN_TIME_EDEFAULT = 0;

	/**
	 * The cached value of the '{@link #getMinTime() <em>Min Time</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getMinTime()
	 * @generated
	 * @ordered
	 */
	protected int minTime = MIN_TIME_EDEFAULT;

	/**
	 * The default value of the '{@link #getMaxTime() <em>Max Time</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getMaxTime()
	 * @generated
	 * @ordered
	 */
	protected static final int MAX_TIME_EDEFAULT = 0;

	/**
	 * The cached value of the '{@link #getMaxTime() <em>Max Time</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getMaxTime()
	 * @generated
	 * @ordered
	 */
	protected int maxTime = MAX_TIME_EDEFAULT;

	/**
	 * The cached value of the '{@link #getResources() <em>Resources</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getResources()
	 * @generated
	 * @ordered
	 */
	protected EList<ResourceType> resources;

	/**
	 * The cached value of the '{@link #getGuidanceGFX() <em>Guidance GFX</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getGuidanceGFX()
	 * @generated
	 * @ordered
	 */
	protected EList<Guidance> guidanceGFX;

	/**
	 * The cached value of the '{@link #getResourcesGFX() <em>Resources GFX</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getResourcesGFX()
	 * @generated
	 * @ordered
	 */
	protected EList<Resource> resourcesGFX;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ProcessImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return SimplePDLPackage.Literals.PROCESS;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getName() {
		return name;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setName(String newName) {
		String oldName = name;
		name = newName;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, SimplePDLPackage.PROCESS__NAME, oldName, name));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<ProcessElement> getProcessElements() {
		if (processElements == null) {
			processElements = new EObjectContainmentEList<ProcessElement>(ProcessElement.class, this, SimplePDLPackage.PROCESS__PROCESS_ELEMENTS);
		}
		return processElements;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public int getMinTime() {
		return minTime;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setMinTime(int newMinTime) {
		int oldMinTime = minTime;
		minTime = newMinTime;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, SimplePDLPackage.PROCESS__MIN_TIME, oldMinTime, minTime));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public int getMaxTime() {
		return maxTime;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setMaxTime(int newMaxTime) {
		int oldMaxTime = maxTime;
		maxTime = newMaxTime;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, SimplePDLPackage.PROCESS__MAX_TIME, oldMaxTime, maxTime));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<ResourceType> getResources() {
		if (resources == null) {
			resources = new EObjectContainmentEList<ResourceType>(ResourceType.class, this, SimplePDLPackage.PROCESS__RESOURCES);
		}
		return resources;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Guidance> getGuidanceGFX() {
		if (guidanceGFX == null) {
			guidanceGFX = new EObjectContainmentEList<Guidance>(Guidance.class, this, SimplePDLPackage.PROCESS__GUIDANCE_GFX);
		}
		return guidanceGFX;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Resource> getResourcesGFX() {
		if (resourcesGFX == null) {
			resourcesGFX = new EObjectContainmentEList<Resource>(Resource.class, this, SimplePDLPackage.PROCESS__RESOURCES_GFX);
		}
		return resourcesGFX;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case SimplePDLPackage.PROCESS__PROCESS_ELEMENTS:
				return ((InternalEList<?>)getProcessElements()).basicRemove(otherEnd, msgs);
			case SimplePDLPackage.PROCESS__RESOURCES:
				return ((InternalEList<?>)getResources()).basicRemove(otherEnd, msgs);
			case SimplePDLPackage.PROCESS__GUIDANCE_GFX:
				return ((InternalEList<?>)getGuidanceGFX()).basicRemove(otherEnd, msgs);
			case SimplePDLPackage.PROCESS__RESOURCES_GFX:
				return ((InternalEList<?>)getResourcesGFX()).basicRemove(otherEnd, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case SimplePDLPackage.PROCESS__NAME:
				return getName();
			case SimplePDLPackage.PROCESS__PROCESS_ELEMENTS:
				return getProcessElements();
			case SimplePDLPackage.PROCESS__MIN_TIME:
				return new Integer(getMinTime());
			case SimplePDLPackage.PROCESS__MAX_TIME:
				return new Integer(getMaxTime());
			case SimplePDLPackage.PROCESS__RESOURCES:
				return getResources();
			case SimplePDLPackage.PROCESS__GUIDANCE_GFX:
				return getGuidanceGFX();
			case SimplePDLPackage.PROCESS__RESOURCES_GFX:
				return getResourcesGFX();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case SimplePDLPackage.PROCESS__NAME:
				setName((String)newValue);
				return;
			case SimplePDLPackage.PROCESS__PROCESS_ELEMENTS:
				getProcessElements().clear();
				getProcessElements().addAll((Collection<? extends ProcessElement>)newValue);
				return;
			case SimplePDLPackage.PROCESS__MIN_TIME:
				setMinTime(((Integer)newValue).intValue());
				return;
			case SimplePDLPackage.PROCESS__MAX_TIME:
				setMaxTime(((Integer)newValue).intValue());
				return;
			case SimplePDLPackage.PROCESS__RESOURCES:
				getResources().clear();
				getResources().addAll((Collection<? extends ResourceType>)newValue);
				return;
			case SimplePDLPackage.PROCESS__GUIDANCE_GFX:
				getGuidanceGFX().clear();
				getGuidanceGFX().addAll((Collection<? extends Guidance>)newValue);
				return;
			case SimplePDLPackage.PROCESS__RESOURCES_GFX:
				getResourcesGFX().clear();
				getResourcesGFX().addAll((Collection<? extends Resource>)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case SimplePDLPackage.PROCESS__NAME:
				setName(NAME_EDEFAULT);
				return;
			case SimplePDLPackage.PROCESS__PROCESS_ELEMENTS:
				getProcessElements().clear();
				return;
			case SimplePDLPackage.PROCESS__MIN_TIME:
				setMinTime(MIN_TIME_EDEFAULT);
				return;
			case SimplePDLPackage.PROCESS__MAX_TIME:
				setMaxTime(MAX_TIME_EDEFAULT);
				return;
			case SimplePDLPackage.PROCESS__RESOURCES:
				getResources().clear();
				return;
			case SimplePDLPackage.PROCESS__GUIDANCE_GFX:
				getGuidanceGFX().clear();
				return;
			case SimplePDLPackage.PROCESS__RESOURCES_GFX:
				getResourcesGFX().clear();
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case SimplePDLPackage.PROCESS__NAME:
				return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
			case SimplePDLPackage.PROCESS__PROCESS_ELEMENTS:
				return processElements != null && !processElements.isEmpty();
			case SimplePDLPackage.PROCESS__MIN_TIME:
				return minTime != MIN_TIME_EDEFAULT;
			case SimplePDLPackage.PROCESS__MAX_TIME:
				return maxTime != MAX_TIME_EDEFAULT;
			case SimplePDLPackage.PROCESS__RESOURCES:
				return resources != null && !resources.isEmpty();
			case SimplePDLPackage.PROCESS__GUIDANCE_GFX:
				return guidanceGFX != null && !guidanceGFX.isEmpty();
			case SimplePDLPackage.PROCESS__RESOURCES_GFX:
				return resourcesGFX != null && !resourcesGFX.isEmpty();
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (name: ");
		result.append(name);
		result.append(", minTime: ");
		result.append(minTime);
		result.append(", maxTime: ");
		result.append(maxTime);
		result.append(')');
		return result.toString();
	}

} //ProcessImpl
